package com.day0930;

import java.util.ArrayList;
import java.util.Arrays;

public class MyArrayList<T> implements MyList<T>{
    Object[] data = new Object[5];
    private int size = 0;
    @Override
    public void add(T t) {
        if (size > data.length){
            data = Arrays.copyOf(data,data.length*3/2+1);
        }
        data[size] = t;
        size++;
    }

    @Override
    public int size() {
        return this.size;
    }

    @Override
    public T get(int index) {
        return (T)data[index];
    }
}
